<?php

use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;
class Orders extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function up()
    {
        $table = $this->table('orders', array('comment' => '订单表'));
        $table->addColumn('number', 'string', array('limit' => 255, 'comment' => '订单编号','null'=>true))
              ->addColumn('rent_user_id', 'integer', array('comment' => '订单用户ID','null'=>true))
			  ->addColumn('rent_user_account', 'string', array('comment' => '订单用户账号','default'=>''))
              ->addColumn('rent_contact_id', 'string', array('limit' => 255, 'comment' => '订单用户联系人id','null'=>true))
              ->addColumn('status', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '订单状态','null'=>true))
              ->addColumn('source', 'integer', array('limit' => MysqlAdapter::INT_TINY, 'comment' => '订单来源','null'=>true))
              ->addColumn('paid_at', 'timestamp', array('null' => true, 'comment' => '支付时间'))
              ->addColumn('created_at', 'timestamp', array('default' => 'CURRENT_TIMESTAMP'))
              ->addColumn('updated_at', 'timestamp', array('null' => true))
              ->addColumn('caravan_id', 'integer', array('comment' => '房车ID','null'=>true))
              ->addColumn('camp_id', 'integer', array('comment' => '营地ID','null'=>true))
              ->addColumn('service_fee', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '服务费','null'=>true))
              ->addColumn('deposit', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '定金','null'=>true))
              ->addColumn('total_intergral', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '总旅行币','null' => true))
              ->addColumn('total_money', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '出租消费钱数','null' => true))
              ->addColumn('total_amount', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '总钱数'))
              ->addColumn('take_car_area', 'string', array('limit' => 255, 'comment' => '取车地点','null'=>true))
              ->addColumn('leave_car_area', 'string', array('limit' => 255, 'comment' => '还车地点','null'=>true))
              ->addColumn('take_car_date', 'string', array('limit' => 255, 'comment' => '取车时间','null'=>true))
              ->addColumn('leave_car_date', 'string', array('limit' => 255, 'comment' => '还车时间','null'=>true))
              //未登录联系人方式
              ->addColumn('contact_phone', 'string', array('limit' => 255, 'comment' => '未登录联系人方式手机号','null' => true))
              ->addColumn('contact_email', 'string', array('limit' => 255, 'comment' => '未登录联系人方式邮箱','null' => true))
              ->addColumn('contact_name', 'string', array('limit' => 255, 'comment' => '未登录联系人方式联系人','null' => true))
              ->addColumn('contact_number', 'string', array('limit' => 255, 'comment' => '未登录联系人方式证件号码','null' => true))
              ->addColumn('contact_type', 'string', array('limit' => 255, 'comment' => '未登录联系人方式证件类型','null' => true))
              //结束
              ->addColumn('caravan_user_id', 'integer', array('comment' => '房车拥有者ID'))  
              ->addColumn('pay_chose', 'string', array('limit' => 50, 'comment' => '支付方式','null' => true))
              

              ->addIndex('id')
              ->addIndex('status')
              ->save();   
    }
    public function down()
    {
        $this->dropTable('orders');
    }
}
